utils.on(tbody, 'click', function (e) {
    const target = e.target;
    const tr = target.parentNode.parentNode;
    const spans = tr.querySelectorAll('span');
    if (Array.from(target.classList).includes('btn-edit')) {
        //编辑
        tr.classList.add('edit');
        spans.forEach((span) => {
            span.nextElementSibling.value = span.innerHTML;
        })
    } else if (Array.from(target.classList).includes('btn-ok')) {
        //确定
        const name = tr.querySelector('.editName').value,
            price = tr.querySelector('.editPrice').value,
            num = tr.querySelector('.editNum').value,
            id = tr.getAttribute('data-id');
        utils.fetch('api/shop/edit.php', { name, price, num, id }).then((resp) => {
            if (resp.code === 200) {
                tr.classList.remove('edit');
                spans.forEach((span) => {
                    span.innerHTML = span.nextElementSibling.value;
                })
                getData();
                alert(resp.body.msg);
            } else {
                alert(resp.body.msg);
            }
        })
    } else if (Array.from(target.classList).includes('btn-del')) {
        //删除
        if (confirm('确定删除吗？')) {
            const id = tr.getAttribute('data-id');
            utils.fetch('api/shop/delete.php', { id }).then((resp) => {
                if (resp.code === 200) {
                    getData();
                    alert(resp.body.msg);
                } else {
                    alert(resp.body.msg);
                }
            })
        }
    } else if (Array.from(target.classList).includes('btn-cancel')) {
        //取消
        tr.classList.remove('edit');
        spans.forEach((span) => {
            span.innerHTML = span.nextElementSibling.value;
        })
    }
})